package com.action.ui.adapter;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.base.app_core.View.xrecyclerview.RecyclerAdapter;
import com.base.app_core.View.xrecyclerview.RecyclerViewHolder;
import com.base.app_core.model.PoiList;
import com.xinglai.yun.R;

import butterknife.BindView;

/**
 * Created by jiansheng.li on 2017/10/11.
 */

public class ShowHisLocationAdapter extends RecyclerAdapter<PoiList,
        ShowHisLocationAdapter.ViewHolder> {

    private onLocationSeleted circleHandlerInterface;

    @Override
    protected void fillData(final PoiList item, final ViewHolder holder) {
        holder.city.setText(item.getTitle());
        holder.address.setText(item.getAddress());
        holder.container.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (circleHandlerInterface != null) {
                    circleHandlerInterface.onSeleted(item);
                }
            }
        });
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_hist_location_layout;
    }

    public class ViewHolder extends RecyclerViewHolder {

        @BindView(R.id.city)
        TextView city;

        @BindView(R.id.address)
        TextView address;

        @BindView(R.id.container)
        RelativeLayout container;

        public ViewHolder(View itemView) {
            super(itemView);
        }
    }

    public void setHistoryHandlerInterface(onLocationSeleted circleHandlerInterface) {
        this.circleHandlerInterface = circleHandlerInterface;
    }

    public interface onLocationSeleted {
        void onSeleted(PoiList item);
    }
}
